package com.ctshk.rpc.hotel.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.hotel.dto.HotelProductCostDTO;
import com.ctshk.rpc.hotel.dto.HotelProductCostPriceDTO;
import com.ctshk.rpc.hotel.entity.HotelProductCost;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 酒店产品成本 Mapper 接口
 * </p>
 *
 * @author yinhuan
 * @since 2021-03-03
 */
public interface HotelProductCostMapper extends BaseMapper<HotelProductCost> {
    /**
     * 根据产品id查询产品成本集合
     * @param hotelProductId
     * @return
     */
    @Select("<script>"+"select id,hotel_product_id,cost_name,currency_id,currency_name from t_hotel_productt_cost \n" +
            "where hotel_product_id = #{hotelProductId} \n" +
            "</script>")
    List<HotelProductCostDTO> queryList(@Param("hotelProductId") Long hotelProductId);

    /**
     * 查询产品成本价格
     */
    @Select("<script>"+"select b.hotel_id,b.name,a.currency_id,a.currency_name,a.price from t_hotel_product_cost a " +
            "left join t_hotel_product b on a.hotel_product_id  = b.id \n" +
            "left join t_hotel_product_cost_date c on a.id = c.cost_id \n" +
            "WHERE b.is_deleted = 0 \n" +
            "AND c.date_begin &lt;=#{queryDate} and c.date_end &gt;=#{queryDate}\n" +
            "AND b.id =#{productId}\n" +
            "</script>")
    List<HotelProductCostPriceDTO> queryPrice(@Param("productId") Long productId, @Param("queryDate") LocalDate queryDate);

}
